<!--  -->
<template>
  <div>

  <el-button @click="add">添加老人</el-button>
  老人管理
  <EleTtable :data="tableData.list" :columns="columns" :total="tableData.counts">
   <template #operate="{row}">
    <el-button @click="handleRecord(row)" type="primary">档案管理</el-button>
    <el-button @click="handleWork(row)" type="primary">排版</el-button>
    <el-button @click="handleTask(row)" type="primary">计划任务</el-button>
  </template>
  </EleTtable>
  </div>
</template>

<script lang='ts' setup>
import { reactive,toRefs,ref,onMounted} from 'vue'
import { useRouter } from 'vue-router';
import EleTtable, { ColumnType } from '../../components/table/EleTtable.vue';
import { Elderly, ElderlyParams, ResponseElderly } from '../../apis/elderly/type';
import { getElderlyList } from '../../apis/elderly/elderly';
const router = useRouter();

const columns = ref<ColumnType[]>([

  {
    label: "序号",
    prop: "id"
  },
  {
    label: "老人姓名",
    prop: "name"
  },
  {
    label: "操作",
    prop: "operate",
    slot:true,
    slotName:"operate"
  },
  


]);

const params = reactive<ElderlyParams>({
  adminName: "",
  name: "",
  page: 1,
  pageSize: 10
})

//机构列表

let tableData = reactive<ResponseElderly>({
  counts: 0,
  pageSize: 0,
  list: []
});
const getElderlyData = async () => {

const res = await getElderlyList(params);

Object.assign(tableData, res.data)



}
getElderlyData();
const add=()=>{

    router.push('/market/elderly-add')

}
const handleRecord=(item:Elderly)=>{

    router.push('/market/records?id='+item.id)

}
const handleTask=(item:Elderly)=>{

router.push('/market/schedule?id='+item.id)

}


//排版

const handleWork=(item:Elderly)=>{

router.push('/market/work?id='+item.id)

}
</script>
<style scoped>
</style>